using System.Collections.Generic;
using Volo.Abp.Authorization.Permissions;

namespace AuthService.Permissions
{
    /// <summary>
    /// 认证授权服务权限定义
    /// </summary>
    public static class AuthServicePermissions
    {
        public const string GroupName = "AuthService";

        public static class Login
        {
            public const string Default = GroupName + ".Login";
            public const string Password = Default + ".Password";
            public const string TwoFactor = Default + ".TwoFactor";
            public const string Social = Default + ".Social";
            public const string SingleSignOn = Default + ".SingleSignOn";
            public const string ApiKey = Default + ".ApiKey";
            public const string Passwordless = Default + ".Passwordless";
        }

        public static class ManageTokens
        {
            public const string Default = GroupName + ".ManageTokens";
            public const string Create = Default + ".Create";
            public const string Update = Default + ".Update";
            public const string Delete = Default + ".Delete";
            public const string Revoke = Default + ".Revoke";
            public const string Refresh = Default + ".Refresh";
            public const string Validate = Default + ".Validate";
            public const string View = Default + ".View";
            public const string Export = Default + ".Export";
            public const string Import = Default + ".Import";
        }

        public static class ManageClients
        {
            public const string Default = GroupName + ".ManageClients";
            public const string Create = Default + ".Create";
            public const string Update = Default + ".Update";
            public const string Delete = Default + ".Delete";
            public const string View = Default + ".View";
            public const string ManageSecrets = Default + ".ManageSecrets";
            public const string ManagePermissions = Default + ".ManagePermissions";
            public const string ManageScopes = Default + ".ManageScopes";
            public const string Enable = Default + ".Enable";
            public const string Disable = Default + ".Disable";
        }

        public static class ManageScopes
        {
            public const string Default = GroupName + ".ManageScopes";
            public const string Create = Default + ".Create";
            public const string Update = Default + ".Update";
            public const string Delete = Default + ".Delete";
            public const string View = Default + ".View";
            public const string Assign = Default + ".Assign";
            public const string Revoke = Default + ".Revoke";
        }

        public static class ManageSessions
        {
            public const string Default = GroupName + ".ManageSessions";
            public const string View = Default + ".View";
            public const string ViewAll = Default + ".ViewAll";
            public const string Revoke = Default + ".Revoke";
            public const string RevokeAll = Default + ".RevokeAll";
            public const string Extend = Default + ".Extend";
            public const string Monitor = Default + ".Monitor";
            public const string ManageTrust = Default + ".ManageTrust";
        }

        public static class ManageTwoFactor
        {
            public const string Default = GroupName + ".ManageTwoFactor";
            public const string Enable = Default + ".Enable";
            public const string Disable = Default + ".Disable";
            public const string Setup = Default + ".Setup";
            public const string Reset = Default + ".Reset";
            public const string BackupCodes = Default + ".BackupCodes";
            public const string Verify = Default + ".Verify";
            public const string ManageMethods = Default + ".ManageMethods";
            public const string ForceEnable = Default + ".ForceEnable";
        }

        public static class ManageSecurity
        {
            public const string Default = GroupName + ".ManageSecurity";
            public const string View = Default + ".View";
            public const string ManagePolicies = Default + ".ManagePolicies";
            public const string ViewEvents = Default + ".ViewEvents";
            public const string ManageEvents = Default + ".ManageEvents";
            public const string ManageRisks = Default + ".ManageRisks";
            public const string ManageThreats = Default + ".ManageThreats";
            public const string ManageAlerts = Default + ".ManageAlerts";
            public const string ViewAnalytics = Default + ".ViewAnalytics";
        }

        public static class ViewAuditLogs
        {
            public const string Default = GroupName + ".ViewAuditLogs";
            public const string Login = Default + ".Login";
            public const string Token = Default + ".Token";
            public const string Session = Default + ".Session";
            public const string Security = Default + ".Security";
            public const string Admin = Default + ".Admin";
            public const string Export = Default + ".Export";
            public const string Filter = Default + ".Filter";
            public const string Search = Default + ".Search";
        }

        public static class ManagePolicies
        {
            public const string Default = GroupName + ".ManagePolicies";
            public const string Create = Default + ".Create";
            public const string Update = Default + ".Update";
            public const string Delete = Default + ".Delete";
            public const string Enable = Default + ".Enable";
            public const string Disable = Default + ".Disable";
            public const string View = Default + ".View";
            public const string Test = Default + ".Test";
            public const string Apply = Default + ".Apply";
        }

        public static class ManageIntegrations
        {
            public const string Default = GroupName + ".ManageIntegrations";
            public const string Create = Default + ".Create";
            public const string Update = Default + ".Update";
            public const string Delete = Default + ".Delete";
            public const string Test = Default + ".Test";
            public const string Sync = Default + ".Sync";
            public const string View = Default + ".View";
            public const string ManageCredentials = Default + ".ManageCredentials";
            public const string ManageWebhooks = Default + ".ManageWebhooks";
        }

        /// <summary>
        /// 获取所有权限
        /// </summary>
        public static List<string> GetAll()
        {
            return new List<string>
            {
                // 登录权限
                Login.Default,
                Login.Password,
                Login.TwoFactor,
                Login.Social,
                Login.SingleSignOn,
                Login.ApiKey,
                Login.Passwordless,

                // 令牌管理权限
                ManageTokens.Default,
                ManageTokens.Create,
                ManageTokens.Update,
                ManageTokens.Delete,
                ManageTokens.Revoke,
                ManageTokens.Refresh,
                ManageTokens.Validate,
                ManageTokens.View,
                ManageTokens.Export,
                ManageTokens.Import,

                // 客户端管理权限
                ManageClients.Default,
                ManageClients.Create,
                ManageClients.Update,
                ManageClients.Delete,
                ManageClients.View,
                ManageClients.ManageSecrets,
                ManageClients.ManagePermissions,
                ManageClients.ManageScopes,
                ManageClients.Enable,
                ManageClients.Disable,

                // 作用域管理权限
                ManageScopes.Default,
                ManageScopes.Create,
                ManageScopes.Update,
                ManageScopes.Delete,
                ManageScopes.View,
                ManageScopes.Assign,
                ManageScopes.Revoke,

                // 会话管理权限
                ManageSessions.Default,
                ManageSessions.View,
                ManageSessions.ViewAll,
                ManageSessions.Revoke,
                ManageSessions.RevokeAll,
                ManageSessions.Extend,
                ManageSessions.Monitor,
                ManageSessions.ManageTrust,

                // 双因子认证权限
                ManageTwoFactor.Default,
                ManageTwoFactor.Enable,
                ManageTwoFactor.Disable,
                ManageTwoFactor.Setup,
                ManageTwoFactor.Reset,
                ManageTwoFactor.BackupCodes,
                ManageTwoFactor.Verify,
                ManageTwoFactor.ManageMethods,
                ManageTwoFactor.ForceEnable,

                // 安全管理权限
                ManageSecurity.Default,
                ManageSecurity.View,
                ManageSecurity.ManagePolicies,
                ManageSecurity.ViewEvents,
                ManageSecurity.ManageEvents,
                ManageSecurity.ManageRisks,
                ManageSecurity.ManageThreats,
                ManageSecurity.ManageAlerts,
                ManageSecurity.ViewAnalytics,

                // 审计日志权限
                ViewAuditLogs.Default,
                ViewAuditLogs.Login,
                ViewAuditLogs.Token,
                ViewAuditLogs.Session,
                ViewAuditLogs.Security,
                ViewAuditLogs.Admin,
                ViewAuditLogs.Export,
                ViewAuditLogs.Filter,
                ViewAuditLogs.Search,

                // 策略管理权限
                ManagePolicies.Default,
                ManagePolicies.Create,
                ManagePolicies.Update,
                ManagePolicies.Delete,
                ManagePolicies.Enable,
                ManagePolicies.Disable,
                ManagePolicies.View,
                ManagePolicies.Test,
                ManagePolicies.Apply,

                // 集成管理权限
                ManageIntegrations.Default,
                ManageIntegrations.Create,
                ManageIntegrations.Update,
                ManageIntegrations.Delete,
                ManageIntegrations.Test,
                ManageIntegrations.Sync,
                ManageIntegrations.View,
                ManageIntegrations.ManageCredentials,
                ManageIntegrations.ManageWebhooks
            };
        }
    }
}
